<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter"%>
<%@ page import="org.apache.shiro.authc.ExcessiveAttemptsException"%>
<%@ page import="org.apache.shiro.authc.IncorrectCredentialsException"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
	<title>欢迎您登录</title>
	
<link rel="stylesheet" href="${ctx}/static/plugin/bootstrap/css/bootstrap.min.css"  />
<script>
	
	function sel(obj){
		var serial = '${serial}';
		parent.close(obj,serial);
	}
	
	$(document).ready(function() {
		mz_datatbles.dt();
	});
	
	var pop = '${pop}';
	var oTable;
	mz_datatbles = {
		dt:function(){
			if($('#listTable').length) {
				var aColumns = [
					{'name':'resourcesName','value':'资源名称'},	
					{'name':'resourcesDesc','value':'资源说明'},	
					{'name':'resourcesStr','value':'资源类型'},	
					{'name':'createTimeStr','value':'创建日期'},
					{'name':'createBy','value':'创建人'}
				];
				oTable = $("#listTable").dataTable({
		    		"fnServerParams": function ( aoData ) {
		    			jQuery.each( $("form#listForm").serializeArray(), function(i, field){
		    				aoData.push( field );    
						});
		    		} ,
		        	"bServerSide": true,
		        	"bProcessing": true,
		        	"bSort" : true, 
		        	"sPaginationType": "bootstrap",
		        	"sDom": "<r>t<'row'<'span6'li><'span6'p>>",
		        	"sAjaxSource": "${ctx}/cases/resources/list",
		        	"oLanguage": {  
		        		"sProcessing": "数据加载中",
		        		"sLoadingRecords": "Please wait - loading...",
		        		"sLengthMenu": "每页显示 _MENU_ 行&nbsp;",
		        		"sSearch": "_INPUT_",
		        		"oPaginate": {       "sFirst": "首页" ,  "sPrevious": "前页" ,"sNext": "下页", "sLast": "尾页"     },
		        		"sZeroRecords": "未找到符合条件的数据",
		        		"sEmptyTable": "未找到符合条件的数据"
		        	} ,
		       	 	"aoColumns": [
						{ "mDataProp": "resourcesName", "sName": "resourcesName", "sClass": "center" },
						{ "mDataProp": "resourcesDesc", "sName": "resourcesDesc", "sClass": "center" },
						{ "bSortable": false, "mDataProp": null, "sClass": "center",
							"fnRender" : function(oObj) { 
								var html = '<img id="preview" width="60px" height="60px"';
								if(pop=="1"){
									html= html+'onclick="sel('+oObj.aData.resourcesId+')"';
								}
								html = html+'src="${ctx}/cases/resources/viewPhoto/'+oObj.aData.resourcesId+'"/>'
								return html; 
							}
						},
						//{ "mDataProp": "resourcesStr", "sName": "resourcesStr", "sClass": "center" },
						{ "mDataProp": "createTimeStr", "sName": "createTimeStr", "sClass": "center" },
						{ "mDataProp": "createBy", "sName": "createBy", "sClass": "center" },
						{ "bSortable": false, "mDataProp": null, "sClass": "center",
							"fnRender" : function(oObj) {
								var html;
								if(pop!="1"){
									html = 
									'<a title="删除" class="sepV_a" onclick="return delConfirm()" href="${ctx}/cases/resources/delete/'+oObj.aData.resourcesId+'">' +
									'<i class="icon-trash"></i></a>'
								}else if(pop=="1"){
									html = '选择<input type="radio" id="selr" name="selr" onclick="sel('+oObj.aData.resourcesId+')" value="'+oObj.aData.resourcesId+
									'"/>'
								}
								return html; 
							}
						}
					] ,
					"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
		        		
		        		if(pop!="1"){
							getFrameHeight();
						}
		        		return "&nbsp;"+(iTotal>0?iStart:0)+" ~ "+iEnd+" 行 总共"+iTotal+"行 ";  
		        	} 
		    	});
			}
		}
	};
var message = '${message}';
if(message!=null && message!=""){
	alert(message);
}

function delConfirm(){
	if(confirm("是否真的删除该资源?")){
		return true;
	}else{
		return false;
	}
}

function toSave(){
	window.location.href = "${ctx}/cases/resources/create";
}
</script>
</head>

<body>
    <div>
      <div id="jCrumbs" class="breadCrumb module">
	    <ul>
	        <li>
	            <a href="#"><i class="icon-home" style="margin-top: 2px;"></i></a>
	        </li>
	        <li>
	            	资源管理
	        </li>
	        <li>
	            	资源列表
	        </li>
	    </ul>
	</div>
	<div class="row-fluid">
   		<div class="span12">
       		<div class="row-fluid">
				<div class="span12">
					<form name="listForm" id="listForm">
						<table class="table table-bordered table-striped table_vam dataTable">
							<tbody>
								<tr>
									<th>资源名称</th>
									<td>
										<input type="text" name="resourcesName" />
									 </td>
								</tr>
								<tr>
									<td colspan="4">								
										<div class="row">
											<div class="span4">
												<div class="dt_actions"><div class="btn-group"></div></div>
											</div>
											<div class="span4 center">
												<button class="btn  btn_search" type="button" onclick="oTable.fnDraw();">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
												<button class="btn" type="reset">重置</button>
											</div>
											<div class="span4">
												<div class="btn-group pull-right">
													<c:if test="${pop!=1}">
														<button class="btn" style="background-color: #D7E6FA" type="button" onclick="toSave()">新增资源</button>
													</c:if>
												</div>
											</div>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</form>
					</div>
				</div>
			<table id="listTable" class="table table-bordered table-striped table_vam dataTable">
            	<thead>
                	<tr>
						<th>资源名称</th>
						<th>资源说明</th>
						<th class="center sorting">缩略图</th>
						<th>创建时间</th>
						<th>创建人</th>
						<th class="center sorting">操作</th>
					</tr>
            	</thead>
            	<tbody>
                	<tr>
                    	<td class="dataTables_empty" colspan="6"></td>
                	</tr>
            	</tbody>
        	</table>
        </div>
    </div>
</div>
</body>
</html>
